package com.xw.service.impl;

import com.xw.dao.NewsDao;
import com.xw.entity.News;
import com.xw.service.NewsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
/**
 * @Description: 针对表【news】的数据库操作Service实现
 * @Author: 72478
 * @Date: 2024/12/18 16:53
 * @Version: 1.0
 */
@Service
public class NewsServiceImpl implements NewsService {

    @Resource
    private NewsDao newsDao;

    @Override
    public boolean publishNews(News news) {
        return newsDao.addNews(news) > 0;
    }

    @Override
    public boolean deleteNews(Integer id) {
        return newsDao.deleteNews(id) > 0;
    }

    @Override
    public boolean updateNews(News news) {
        return newsDao.updateNews(news) > 0;
    }

    @Override
    public News getNewsById(Integer id) {
        return newsDao.getNewsById(id);
    }

    @Override
    public List<News> getAllNews() {
        return  newsDao.getAllNews();
    }

    @Override
    public List<News> searchNewsByKeywords(String keywords) {
        return newsDao.searchNewsByKeywords(keywords);
    }
}
